import java.util.Stack;
//最小栈的模拟实现
class MinStack {
    /** initialize your data structure here. */
    Stack<Integer> stack, minStack;
    public MinStack() {
        stack=new Stack<>();
        minStack=new Stack<>();
    }
    //入栈
    public void push(int x) {
        stack.push(x);
        if(minStack.empty()||x<=minStack.peek()){
            minStack.push(x);
        }
    }
    //出栈
    public void pop() {
        int val=stack.pop();
        if(minStack.peek()==val){
            minStack.pop();
        }
    }
    //栈顶
    public int top() {
        return stack.peek();
    }
    //最小数
    public int min() {
       return minStack.peek();
    }
}
